<?php
/**
 * @package Analyser
 * @author Yves Peeters
 */
include_once "SpiderDB.php";
/**
 * Geeft een report terug van Site Analyser
 */
Class Report{
    
        /**
         * maakt een link met de spiderdatabase
         */
    private $report;
        public function __construct($email,$spider=true,$page=true;$seo=true){
            $this->email = $email
            $this->spider = $spider;
            $this->page = $page;
            $this->seo = $seo;
            $this->db= new SpiderDB();
            $this->report();
        }

        function report(){
            if($this->spider){
            $this->report .= $this->spiderReport();
            }
           /*
              if($this->page){

                $this->report .=$this->pageReport();
            }
            if($this->seo){
                $this->report .=$this->seoReport();
            }*/

        }
        /**
         * haalt allerhande info uit de spiderdatabase en geeft dit als string terug
         * @return String
         */
        function spiderReport(){
            $report = "<h1>Spider Report</h1>";
            $nl = "\n";
            $t = "\t";
            $br = "<br />";
            $to = "->";
            $report .=$t."<div id='foundurls'>Urls found: ".$this->db->countUrls()."</div>".$nl;
            $report .=$t."<div id='badurls'># bad urls: ".$this->db->countBadUrls()."</div>".$nl;
            $report .=$t."<div id='missingurls'>list of missing urls".$nl;
            $badurls = $this->db->getBadUrlsByReferer();
            foreach ( $badurls as $linkset){
                $report .=$t.$t."<a href='".$linkset[1]."'>".$linkset[1]."</a>".$br.$to.$linkset[0].$br;
            }
            $report .="</div>";
            return $report;
          }
}
?>
